﻿using Coldairarrow.Business.Base_IPManager;
using Coldairarrow.Entity.Base_IPManager;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_IPManager
{

    /// <summary>
    /// IP管理控制器
    /// </summary>
    [Route("/Base_IPManager/[controller]/[action]")]
    [OpenApiTag("IP管理控制器")]
    public class ipmanagerController : BaseApiController
    {
        #region DI

        public ipmanagerController(IipmanagerBusiness ipmanagerBus)
        {
            _ipmanagerBus = ipmanagerBus;
        }

        IipmanagerBusiness _ipmanagerBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<ipmanager>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _ipmanagerBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<ipmanager> GetTheData(IdInputDTO input)
        {
            return await _ipmanagerBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(ipmanager data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _ipmanagerBus.AddDataAsync(data);
            }
            else
            {
                await _ipmanagerBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _ipmanagerBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}